package itheima.chap08;

public class ArrayDemo {
    public static void main(String[] args) {
        // 定义字符数组，存储食物信息：土豆 玉米 米饭 面条 红薯
        /*String[] foods = new   String[5];
        foods[0] = "土豆";
        foods[1] = "玉米";
        foods[2] = "米饭";
        foods[3] = "面条";
        foods[4] = "红薯";*/
//        String[] foods = new String[]{ "土豆", "玉米", "米饭", "面条", "红薯"};
        String[] foods = {"土豆", "玉米", "米饭", "面条", "红薯"};
        System.out.println("foods[0]：" + foods[0]);
        System.out.println("foods[1]：" + foods[1]);
        System.out.println("foods[2]：" + foods[2]);
        System.out.println("foods[3]：" + foods[3]);
        System.out.println("foods[4]：" + foods[4]);
//        System.out.println("foods" + foods);\
        /**
         * 直接用foods输出数组，会输出数组的引用地址，不会输出数组中的元素
         * 要想直接输出数组中的元素，需要使用索引定位，然后打印出来
         */

        // 修改数组中的元素
        foods[4] = "大红薯";
        System.out.println("foods[4]：" + foods[4]);
    }
}
